package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DsWd;
import com.ruoyi.system.service.IDsWdService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文档记录Controller
 * 
 * @author tyro
 * @date 2025-03-30
 */
@RestController
@RequestMapping("/system/wd")
public class DsWdController extends BaseController
{
    @Autowired
    private IDsWdService dsWdService;

    /**
     * 查询文档记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:wd:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsWd dsWd)
    {
        startPage();
        List<DsWd> list = dsWdService.selectDsWdList(dsWd);
        return getDataTable(list);
    }

    /**
     * 导出文档记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:wd:export')")
    @Log(title = "文档记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsWd dsWd)
    {
        List<DsWd> list = dsWdService.selectDsWdList(dsWd);
        ExcelUtil<DsWd> util = new ExcelUtil<DsWd>(DsWd.class);
        util.exportExcel(response, list, "文档记录数据");
    }

    /**
     * 获取文档记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wd:query')")
    @GetMapping(value = "/{wdId}")
    public AjaxResult getInfo(@PathVariable("wdId") Long wdId)
    {
        return success(dsWdService.selectDsWdByWdId(wdId));
    }

    /**
     * 新增文档记录
     */
    @PreAuthorize("@ss.hasPermi('system:wd:add')")
    @Log(title = "文档记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsWd dsWd)
    {
        return toAjax(dsWdService.insertDsWd(dsWd));
    }

    /**
     * 修改文档记录
     */
    @PreAuthorize("@ss.hasPermi('system:wd:edit')")
    @Log(title = "文档记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsWd dsWd)
    {
        return toAjax(dsWdService.updateDsWd(dsWd));
    }

    /**
     * 删除文档记录
     */
    @PreAuthorize("@ss.hasPermi('system:wd:remove')")
    @Log(title = "文档记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wdIds}")
    public AjaxResult remove(@PathVariable Long[] wdIds)
    {
        return toAjax(dsWdService.deleteDsWdByWdIds(wdIds));
    }
}
